package com.jim.healio.storage;

import com.jim.healio.dto.History;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 全局记忆管理器
 */
@Component
public class MemoryManager {

    private final Map<String, History> historyMap = new ConcurrentHashMap<>(); //(sessionId,)

    public History getHistory(String sessionId) {
        return historyMap.get(sessionId);
    }

    public void addHistory(String sessionId, History history) {
        historyMap.put(sessionId, history);
    }

    public void removeHistory(String sessionId) {
        historyMap.remove(sessionId);
    }
}
